/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "detalle_ped_cli")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetallePedCli.findAll", query = "SELECT d FROM DetallePedCli d"),
    @NamedQuery(name = "DetallePedCli.findByCodPedCli", query = "SELECT d FROM DetallePedCli d WHERE d.detallePedCliPK.codPedCli = :codPedCli"),
    @NamedQuery(name = "DetallePedCli.findByLinea", query = "SELECT d FROM DetallePedCli d WHERE d.detallePedCliPK.linea = :linea"),
    @NamedQuery(name = "DetallePedCli.findByCantidad", query = "SELECT d FROM DetallePedCli d WHERE d.cantidad = :cantidad"),
    @NamedQuery(name = "DetallePedCli.findByPrecio", query = "SELECT d FROM DetallePedCli d WHERE d.precio = :precio")})
public class DetallePedCli implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetallePedCliPK detallePedCliPK;
    @Column(name = "cantidad")
    private Short cantidad;
    @Basic(optional = false)
    @Column(name = "precio")
    private double precio;
    @JoinColumn(name = "cod_stock", referencedColumnName = "cod_stock")
    @ManyToOne(optional = false)
    private Productos codStock;
    @JoinColumn(name = "cod_ped_cli", referencedColumnName = "cod_ped_cli", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private PedidoCliente pedidoCliente;

    public DetallePedCli() {
    }

    public DetallePedCli(DetallePedCliPK detallePedCliPK) {
        this.detallePedCliPK = detallePedCliPK;
    }

    public DetallePedCli(DetallePedCliPK detallePedCliPK, double precio) {
        this.detallePedCliPK = detallePedCliPK;
        this.precio = precio;
    }

    public DetallePedCli(int codPedCli, short linea) {
        this.detallePedCliPK = new DetallePedCliPK(codPedCli, linea);
    }

    public DetallePedCliPK getDetallePedCliPK() {
        return detallePedCliPK;
    }

    public void setDetallePedCliPK(DetallePedCliPK detallePedCliPK) {
        this.detallePedCliPK = detallePedCliPK;
    }

    public Short getCantidad() {
        return cantidad;
    }

    public void setCantidad(Short cantidad) {
        this.cantidad = cantidad;
    }

    public double getPrecio() {
        return precio;
    }

    public void setPrecio(double precio) {
        this.precio = precio;
    }

    public Productos getCodStock() {
        return codStock;
    }

    public void setCodStock(Productos codStock) {
        this.codStock = codStock;
    }

    public PedidoCliente getPedidoCliente() {
        return pedidoCliente;
    }

    public void setPedidoCliente(PedidoCliente pedidoCliente) {
        this.pedidoCliente = pedidoCliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detallePedCliPK != null ? detallePedCliPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetallePedCli)) {
            return false;
        }
        DetallePedCli other = (DetallePedCli) object;
        if ((this.detallePedCliPK == null && other.detallePedCliPK != null) || (this.detallePedCliPK != null && !this.detallePedCliPK.equals(other.detallePedCliPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hibernate.entidades.DetallePedCli[ detallePedCliPK=" + detallePedCliPK + " ]";
    }
    
}
